// pages/member/billing/billing.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        currentTab: 0,
        statusBarHeight: "", //顶部的 高度
        isActive: false, //
        isShow: false,
        selectData: ['1', '2', '3', '4', '5', '6', '7', ],
        options: [{
            city_id: '001',
            city_name: '北京'
        }, {
            city_id: '002',
            city_name: '上海'
        }, {
            city_id: '003',
            city_name: '深圳'
        },{
            city_id: '004',
            city_name: '北京1'
        }, {
            city_id: '005',
            city_name: '上海1'
        }, {
            city_id: '006',
            city_name: '深圳1'
        },{
            city_id: '007',
            city_name: '北京2'
        }, {
            city_id: '008',
            city_name: '上海2'
        }, {
            city_id: '009',
            city_name: '深圳2'
        },]
        ,
        currentCompany:'',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(query) {
        // this.data.currentTab = options.currentTab
        this.setData({
            statusBarHeight: app.globalData.statusBarHeight,
            buyer: '',
            status: '',
            more: '',
            currentTab: query.index,
        })
        console.log(query, 1111, this.data.currentTab)

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    swichNav: function (e) {
        var _this = this;
        if (e !== undefined) {
            let currentTab = e.target.dataset.current
            console.log(2, _this.data.currentTab, this.data.isShow)
 
            _this.setData({
                currentTab: currentTab,
                isShow: !this.data.isShow,
                isActive: !this.data.isActive,
            })           
            console.log('点击事件：显示popup',this.data.isActive);
        }
    },
    change(evt){
        console.log(evt.detail,333)
        let getArror = evt.detail
        this.setData({
            currentCompany:getArror
        })
        console.log(this.data.currentCompany,333)
    },

    bindChange: function (e) {
        var _this = this;
        if (!util.isNull(e)) {
            _this.data.currentTab = e.detail.current
        }
        // this.data.pageNum = 1;
        // this.data.orderList = [];
        var buyer = ''; // 买家
        var status = ''; // 状态
        var more = ''; // 更多
        switch (_this.data.currentTab) {
            case 0:
                buyer = '0';
                status = '';
                more = '';
                break;
            case 1:
                buyer = '';
                status = '1';
                more = '';
                break;
            case 2:
                buyer = '';
                status = '';
                more = '2';
                break;
        }
        _this.setData({
            buyer: buyer,
            status: status,
            more: more,
            currentTab: _this.data.currentTab
        })
        // this.loadList() 
    },

    toBuyer(e) {
        var _this = this;
        // if(!this.data.isShow){
        //     this.data.isShow = true;
        // }else
        //     this.data.isShow = false;
        // _this.setData({
        //     isShow:this.data.isShow

        // })

        var index = e.currentTarget.dataset.index;
        this.setData({
            showIndex: index
        })

        console.log(this.data.isShow, e)
    },

    toStatus(e) {
        var _this = this;
        if (!this.data.isShow) {
            this.data.isShow = true;
        } else
            this.data.isShow = false;
        _this.setData({
            isShow: this.data.isShow
        })
        console.log(this.data.isShow, e)
    },

    toMore(e) {
        var _this = this;
        if (!this.data.isShow) {
            this.data.isShow = true;
        } else
            this.data.isShow = false;
        _this.setData({
            isShow: this.data.isShow
        })
        console.log(this.data.isShow, e)
    },
    navTo() {
        let p = getCurrentPages().length;
        if (p <= 1) {
            wx.switchTab({
                url: '/pages/tabBar/mine/mine',
            })
        } else {
            wx.navigateBack({
                delta: 1
            })
        }
    },





    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})